package spring.lottery.common.pojo;

import lombok.Data;
import lombok.NoArgsConstructor;
import spring.lottery.common.exceptionCode.ExceptionCodeModel;
import spring.lottery.common.exceptionCode.ResponseCodes;

import java.io.Serializable;

@Data
@NoArgsConstructor
public class ResponseMode{
    Integer code;
    String msg;
    Object data;

    public ResponseMode(ExceptionCodeModel code) {
        this.code = code.getCode();
        this.msg = code.getMessage();
        this.data = null;
    }

    public  ResponseMode(ExceptionCodeModel code, Object data) {
        this.code = code.getCode();
        this.msg = code.getMessage();
        this.data = data;
    }

    public ResponseMode(Integer code,String message) {
        this.code = code;
        this.msg = message;
        this.data = null;
    }

    public ResponseMode(Integer code,String message, Object data) {
        this.code = code;
        this.msg = message;
        this.data = data;
    }

    public static ResponseMode success(Object data) {
        return new ResponseMode(ResponseCodes.SUCCESS,data);
    }

    public static ResponseMode fail(String message) {
        return new ResponseMode(ResponseCodes.FAIL.getCode(), message);
    }

    public static ResponseMode fail(String message, Object data) {
        return new ResponseMode(ResponseCodes.FAIL.getCode(), message, data);
    }

    public static ResponseMode fail(Integer integer, String message, Object data) {
        return new ResponseMode(integer, message, data);
    }
}
